<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>万用申请单</title>

    <link rel="shortcut icon" href="__STATIC__/layout/favicon.ico">
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <!-- Sweet Alert -->
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/summernote/summernote-bs3.css" rel="stylesheet">

    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <style>

        .note-editable {
            height: 150px
        }

    </style>
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/plugins/webuploader/webuploader.css">
    <link rel="stylesheet" type="text/css" href="__STATIC__/layout/css/demo/webuploader-demo.css">
</head>

<body class="white-bg" style="padding: 3px;font-size: 13px">
<div class="page-heade">
    <h2 class="title_color text-center">公共信息发布</h2>
</div>
<form action="" class="form-inline" id="form1">
    <table class="table table-bordered bud_hei text-center">
        <tr>
            <td style="width: 180px;">主题<span class="colorRed">*</span></td>
            <td class="text-left"><input type="text" class="form-control" name="title"></td>
            <td style="width: 180px;">类型<span class="colorRed">*</span></td>
            <td class="text-left">
                <select name="lx" id="" class="form-control select">
                    <option value="0">请选择</option>
                    {volist name="lx" id="row"}
                    <option value="{$row.id}">{$row.title}</option>
                    {/volist}
                </select>
            </td>
        </tr>
        <tr>
            <td>发布人</td>
            <td class="text-left">{$fbr}</td>
            <td>发布时间</td>
            <td class="text-left" id="applytime"></td>
        </tr>
        <tr>
            <td>是否置顶</td>
            <td class="text-left">
                <label for="iszhidN">
                    <input type="radio" name="sd_sfzd" id="iszhidN" value="0" checked>否
                </label>
                <label for="iszhidY">
                    <input type="radio" name="sd_sfzd" id="iszhidY" value="1">是
                </label>
            </td>
            <td>是否滚动显示</td>
            <td class="text-left">
                <label for="isgdshowN">
                    <input type="radio" name="sd_sfgdxs" id="isgdshowN" value="0" checked>否
                </label>
                <label for="isgdshowY">
                    <input type="radio" name="sd_sfgdxs" id="isgdshowY" value="1">是
                </label>
            </td>
        </tr>
        <tr>
            <td>是否标题加红色</td>
            <td class="text-left">
                <label for="istitleN">
                    <input type="radio" name="sd_sfbtjhs" id="istitleN" value="0" checked>否
                </label>
                <label for="istitleY">
                    <input type="radio" name="sd_sfbtjhs" id="istitleY" value="1">是
                </label>
            </td>
            <td>以上设定的有效日期</td>
            <td class="text-left"><input type="text" name="sd_yxrq" class="form-control layer-date" style="width: 120px" id="nowTime">(超过有效期后，以上三项设定将无效)
            </td>
        </tr>
        <tr>
            <td>内容<span class="colorRed">*</span></td>
            <td colspan="3" class="text-left">
                <div class="ibox float-e-margins" style="margin-bottom: 0">
                    <div class="ibox-content no-padding">

                        <div class="summernote" id="info">
                        </div>

                    </div>
                </div>
            </td>
        </tr>
        <tr>
            <td colspan="4" class="text-left">温馨提醒：本编辑器不支持复杂表单提交，复杂表单请以附件形式提交</td>
        </tr>
    </table>
    <div class="form-group white-bg" style="margin:20px 10px 20px 20px;">
        {if isset($attach)}
        <ul class="list-group">
            {volist name="attach" id="row"}
            <li class="list-group-item">
                <a class="badge badge-primary removeIt" data-id="{$row.id}">移除</a>
                <a href="{$row.path}" target="_blank">{$row.file_name}</a></li>
            {/volist}
        </ul>
        {/if}
        <div id="uploader" class="wu-example">
            <!--用来存放文件信息-->
            <div id="thelist" class="uploader-list"></div>
            <div class="btns">
                <div id="picker">选择文件</div>
                <button id="ctlBtn" class="btn btn-default">开始上传</button>
            </div>
            <input type="hidden" name="attach" id="attach">
            <input type="hidden" name="remove" id="remove">
        </div>
        <span>注：最多上传15个文件，每个文件小于50M,支持格式：</span><br>jpg,bnp,gif,png,jpeg,tif,raw,doc,docx,xls,xlsx,ppt,pptx,txt,pdf,rar,zip,mp4,avi,rmvb,rm,mid,3gp,AVI,3GP,,mpg,mp3,wma,wav
    </div>
    <div class="padding-10 text-center">
        <button class="btn btn-primary" type="button" id="tijiao">提交</button>
        <span class="lr_5"></span>
        <button class="btn btn-warning" type="reset" id="reset">重置</button>
        <span class="lr_5"></span></div>
</form>


<!-- 全局js -->
<script src="__STATIC__/layout/js/jquery.min.js"></script>
<script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
<!-- Sweet alert -->
<script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
<script>
    $(function () {
        $('#tijiao').on('click',function () {
            var param = $(this).closest('form').serialize()
            param += '&content='+$('#info').code()
            $.post('',param,function (data) {
                if(data.success){
                    swal({title:data.msg},function () {
                        parent.layer.close(parent.layer.getFrameIndex(window.name))
                    })
                }else{
                    swal(data.msg)
                }
            },'json')
            return false
        })
        $('body').on('click', 'input[type=text]', function () {
            this.select()
        })
    })
</script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote.min.js"></script>
<script src="__STATIC__/layout/js/plugins/summernote/summernote-zh-CN.js"></script>
<script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
<script>
    laydate({
        elem: "#nowTime",
        event: "focus"
    })
    $("#nowTime").val(getNowFormatDate())
    getNowFormatDate();
    $("#applytime").html(getNowFormatDate())

    function getNowFormatDate() {
        var date = new Date();
        var seperator1 = "-";
        var month = date.getMonth() + 1;
        var strDate = date.getDate();
        if (month >= 1 && month <= 9) {
            month = "0" + month;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var currentdate = date.getFullYear() + seperator1 + month + seperator1 + strDate;
        return currentdate;
    }

    $(document).ready(function () {
        $('.summernote').summernote({
            lang: 'zh-CN'
        });

        $('#fanhui').on('click', function () {
//                    parent.layer.close(parent.layer.getFrameIndex(window.name))
            parent.location.reload();
            return false
        })
    });


    $('#reset').on('click', function () {
        $("#form1 input").each(function () {
            $(this).val('');
        });
        $("#form1 select").each(function () {
            $(this).val('');
        });
        $('#form1').submit()
        return false
    })
</script>
</body>

</html>
<!-- Web Uploader -->
<script type="text/javascript">
    // 添加全局站点信息
    var BASE_URL = '__STATIC__/layout/js/plugins/webuploader';
</script>
<script src="__STATIC__/layout/js/plugins/webuploader/webuploader.min.js"></script>
<script>
    // 文件上传
    jQuery(function() {
        var $ = jQuery,
            $list = $('#thelist'),
            $btn = $('#ctlBtn'),
            state = 'pending',
            uploader;

        var ids = [];
        uploader = WebUploader.create({

            // 不压缩image
            resize: false,

            // swf文件路径
            swf: BASE_URL + '/js/Uploader.swf',

            // 文件接收服务端。
            server: '{:url("upload/fileupload")}',

            // 选择文件的按钮。可选。
            // 内部根据当前运行是创建，可能是input元素，也可能是flash.
            pick: '#picker'
        });

        // 当有文件添加进来的时候
        uploader.on( 'fileQueued', function( file ) {
            $list.append( '<div id="' + file.id + '" class="item">' +
                '<h4 class="info">' + file.name + '</h4>' +
                '<p class="state">等待上传...</p>' +
                '</div>' );
        });

        // 文件上传过程中创建进度条实时显示。
        uploader.on( 'uploadProgress', function( file, percentage ) {
            var $li = $( '#'+file.id ),
                $percent = $li.find('.progress .progress-bar');

            // 避免重复创建
            if ( !$percent.length ) {
                $percent = $('<div class="progress progress-striped active">' +
                    '<div class="progress-bar" role="progressbar" style="width: 0%">' +
                    '</div>' +
                    '</div>').appendTo( $li ).find('.progress-bar');
            }

            $li.find('p.state').text('上传中');

            $percent.css( 'width', percentage * 100 + '%' );
        });

        uploader.on( 'uploadSuccess', function( file,response) {
            if(response.success)
                ids.push(response.id)
            $( '#'+file.id ).find('p.state').text(response.msg);
        });

        uploader.on( 'uploadError', function( file ) {
            $( '#'+file.id ).find('p.state').text('上传出错');
        });

        uploader.on( 'uploadComplete', function( file ) {
            $('#attach').val(ids.join(','))
            $( '#'+file.id ).find('.progress').fadeOut();
        });

        uploader.on( 'all', function( type ) {
            if ( type === 'startUpload' ) {
                state = 'uploading';
            } else if ( type === 'stopUpload' ) {
                state = 'paused';
            } else if ( type === 'uploadFinished' ) {
                state = 'done';
            }

            if ( state === 'uploading' ) {
                $btn.text('暂停上传');
            } else {
                $btn.text('开始上传');
            }
        });

        $btn.on( 'click', function() {
            if ( state === 'uploading' ) {
                uploader.stop();
            } else {
                uploader.upload();
            }
            return false
        });

    });
</script>